package com.feature50.app.forms;

import com.feature50.clarity.Form;
import com.feature50.clarity.FormException;
import com.feature50.clarity.FormUIField;
import com.feature50.clarity.ClarityProgressMonitor;
import com.feature50.clarity.table.ClarityTableModel;
import com.feature50.app.model.Bean;

import javax.swing.JTable;
import java.awt.Container;

public class TestForm extends Form {
    private @FormUIField JTable table1;

    private Bean[] beans;

    protected void createUI(Container container) throws FormException {
        loadFormUI("TestFormUI");
    }

    protected void getData(ClarityProgressMonitor monitor) throws FormException {
        beans = new Bean[] { new Bean("Foo", 10), new Bean("Bar", 20) };
    }

    protected void configureComponents(Container container) throws FormException {
        table1.setModel(new ClarityTableModel(beans, "name, number"));
    }

    public String[] getStylesheetNames() {
        return new String[] { "test.css" };
    }
}
